package com.palfund.eventbus;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

public class NextStickyActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_next_sticky);
        setTitle("NextStickyActivity");
        EventBus.getDefault().register(this);
        EventBus.getDefault().post(new MessageEvent("相同的事件"));
    }

    @Subscribe(sticky = true)
    public void onStickyMessageEvent(MessageEvent message) {
        Log.i("NextStickyActivity", "---onStickyMessageEvent()--->"+message.mMessage);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    @Subscribe
    public void onMessageEvent(MessageEvent message) {
        Log.i("NextStickyActivity", "---onMessageEvent()--->"+message.mMessage);
    }
}
